package cn.ven.service;

import cn.ven.entity.Tag;
import cn.ven.mapper.TagMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TagServiceImpl implements TagService {

    @Autowired
    TagMapper tagMapper;


    @Override
    public void addTag(Tag tag) {
        tagMapper.insert(tag);
    }

    @Override
    public Tag findById(int id) {
        LambdaQueryWrapper<Tag> queryWrapper =new LambdaQueryWrapper();
        queryWrapper.eq(Tag::getId,id);
        return tagMapper.selectById(queryWrapper);
    }

    @Override
    public List<Tag> findAll() {
        return tagMapper.selectAll();
    }

    @Override
    public void updateTag(Tag tag) {
        tagMapper.updateById(tag);
    }

    @Override
    public void delTag(int id) {
        tagMapper.deleteById(id);
    }
}
